"""
@Time    : 2025/7/23 10:10
@Author  : white.tie
@File    : 获取请求主机.py
@Desc    :  响应 主机ip和请求id
"""
import uvicorn
from fastapi import FastAPI, Request

app = FastAPI()

@app.get("/items/{item_id}")
def read_item(item_id: str, request:Request):
    client_host = request.client.host
    return {"item_id": item_id, "client_host": client_host}

if __name__ == '__main__':
    uvicorn.run(app, host="0.0.0.0", port=8001)